package cn.tedu.mall.search.test;

public class fanzhuanliebiao {
    public static void main(String[] args) {
        Node head = new Node(1);
        head.next = new Node(2);
        head.next.next = new Node(3);
        head.next.next.next = new Node(4);
        head.next.next.next.next = new Node(5);
        head.next.next.next.next.next = new Node(6);
        head.next.next.next.next.next.next = new Node(7);

        head = fanZhuan(head);
        Node n = head;
        while (n != null) {
            System.out.println(n.value);
            n = n.next;
        }
    }

    private static Node fanZhuan(Node head) {
        Node current = head;
        Node next = null;
        while (current != null) {
            Node tmp = current.next;
            current.next = next;
            next = current;
            current = tmp;
        }
        return next;
    }

    static class Node {
        int value;
        Node prev;
        Node next;

        Node(int value) {
            this.value = value;
        }
    }
}
